import {each} from 'lodash'
const fs = require('fs')
const path = require('path')

const codeBlocksWithPaths = document.querySelectorAll('code[data-path]')

each(codeBlocksWithPaths, (code) => {
  const codePath = path.join(__dirname, '../', './' + code.dataset.path)
  // console.log(__dirname, '../', './' + code.dataset.path)
  const extension = path.extname(codePath)
  code.classList.add(`language-${extension.substring(1)}`)
  code.textContent = fs.readFileSync(codePath)
})
const highlight = require('highlight.js')
const codeBlocks = document.querySelectorAll('pre code')
each(codeBlocks, (code) => {
  console.log(highlight)
  highlight.highlightBlock(code)
})
